/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package OtherPubs;

/**
 *
 * @author Artemy Gladenko Jun 18, 2015
 */
import java.util.concurrent.TimeUnit;
import net.lightbody.bmp.proxy.ProxyServer;
import static org.junit.Assert.*;

import static org.junit.matchers.JUnitMatchers.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import net.lightbody.bmp.BrowserMobProxyServer;

public class browserMob_test {

  @Test
  public void startWithProxy() throws Exception {
    BrowserMobProxyServer bmp = new BrowserMobProxyServer();
    bmp.rewriteUrl("http://google.com/", "http://mail.ru/");
      
    bmp.start();
    System.out.println("bmp port: " + bmp.getPort());
    

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability(CapabilityType.PROXY, bmp.seleniumProxy());

    WebDriver driver = new ChromeDriver(caps);
    driver.get("http://google.com/");
    assertThat(
        driver.getCurrentUrl(),
        containsString("mail"));

    driver.quit();

    bmp.stop();
  }
}
